<?php
namespace Api\Controller;
use Think\Controller;
class MyInfoController extends Controller {
  public function upInfo(){
   $arraytype=array('head','name','sex','birthday','address');
   $uid=I('uid');
   $where['id']=$uid;
   $type=I('type');
   $data=I('data');
   if(!in_array($type, $arraytype)){
    EchoData('',0,101,'type类型错误',0);
  }
  if($type=='head'){
   $headimgname=time().rand(10000,99999);
   $dirurl='Public/api/imgs/head/'.$headimgname.'.jpg';
   moveFileToDir($data,$dirurl);
   $datase['head']=$dirurl;
 }elseif($type=='name'){
   $datase['name']=$data;
 }elseif($type=='sex'){
   $datase['sex']=$data;
 }elseif($type=='birthday'){
   $datase['birthday']=$data;
 }elseif($type=='address'){
   $datase=D('Area')->toFontGetAreaIdArray($data);

 }
 $upInfo=se('User',$where,$datase);
 if($upInfo){
   $uinfo=D('User')->toIdGetUserInfo($uid);
   EchoData($uinfo);
 }else{
   EchoData('',0,101,'失败',0);
 }
}

//用户端个人资料修改
public function UpUserOrDoctorInfo(){
  $utypearray=array('user','doctor');
  $utype=I('utype');
  if(!in_array(trim($utype), $utypearray)){
    $returninfo='无效utype类型!';
    EchoData($uinfo,0,105,$returninfo,0);
  }
  $head=I('head');
  $headimgname=time().rand(10000,99999);
  $dirurl='Public/api/imgs/head/'.$headimgname.'.jpg';
  moveFileToDir($head,$dirurl);
  $_POST['head']=$dirurl;
  if($utype=='doctor'){
   $status=M('Doctor')->save(I());
   $uinfo=D('Doctor')->toIdGetDoctorInfo(I('id'));
 }else{
   $status=M('User')->save(I());
   $uinfo=D('User')->toIdGetUserInfo(I('id'));
 }
 if($status!=='false'){
  EchoData($uinfo);
}else{
  EchoData('',0,101,'失败',0);
}
}
//医生端获取擅长和类型api
public function GetShanchangAndType(){
  $data['shangchang']=st('doctorClass');
  $data['type']=st('doctorType');
  EchoData($data);
}

}